//
//  UIDevice+Machine.m
//  ITC_iOS
//
//  Created by Benz.L on 13/09/2018.
//  Copyright © 2018 Benz.L. All rights reserved.
//

#import "UIDevice+Machine.h"
#include <sys/sysctl.h>

@implementation UIDevice(Machine)

+ (NSString *)hwMachine {
    static NSString *platform = nil;
    if (!platform) {
        size_t size;
        sysctlbyname("hw.machine", NULL, &size, NULL, 0);
        char *machine = malloc(size);
        sysctlbyname("hw.machine", machine, &size, NULL, 0);
        platform = [NSString stringWithUTF8String:machine];
        free(machine);
    }
    return platform;
}

@end


/*
 https://blog.csdn.net/Vanpoe/article/details/78554009
 if ([machineString isEqualToString:@"iPhone9,1"])   return Chinese_iPhone_7;
 
 if ([machineString isEqualToString:@"iPhone9,2"])   return Chinese_iPhone_7_Plus;
 
 if ([machineString isEqualToString:@"iPhone9,3"])   return American_iPhone_7;
 
 if ([machineString isEqualToString:@"iPhone9,4"])   return American_iPhone_7_Plus;
 
 if ([machineString isEqualToString:@"iPhone10,1"])  return Chinese_iPhone_8;
 
 if ([machineString isEqualToString:@"iPhone10,4"])  return Global_iPhone_8;
 
 if ([machineString isEqualToString:@"iPhone10,2"])  return Chinese_iPhone_8_Plus;
 
 if ([machineString isEqualToString:@"iPhone10,5"])  return Global_iPhone_8_Plus;
 
 if ([machineString isEqualToString:@"iPhone10,3"])  return Chinese_iPhone_X;
 
 if ([machineString isEqualToString:@"iPhone10,6"])  return Global_iPhone_X;
 */
